home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.4)
-
- import poly
- N = 5
- P = poly.plus(poly.one(0, 2), poly.one(2, 1))
-
- def mod(x, y):
- return divmod(x, y)[1]
-
-
- def norm(a, n, p):
- a = poly.modulo(a, p)
- a = a[:]
- for i in range(len(a)):
- a[i] = mod(a[i], n)
-
- a = poly.normalize(a)
- return a
-
-
- def make_all(mat):
- all = []
- for row in mat:
- for a in row:
- all.append(a)
-
-
- return all
-
-
- def make_elements(n, d):
- if d == 0:
- return [
- poly.one(0, 0)]
-
- sub = make_elements(n, d - 1)
- all = []
- for a in sub:
- for i in range(n):
- all.append(poly.plus(a, poly.one(d - 1, i)))
-
-
- return all
-
-
- def make_inv(all, n, p):
- x = poly.one(1, 1)
- inv = []
- for a in all:
- inv.append(norm(poly.times(a, x), n, p))
-
- return inv
-
-
- def checkfield(n, p):
- all = make_elements(n, len(p) - 1)
- inv = make_inv(all, n, p)
- all1 = all[:]
- inv1 = inv[:]
- all1.sort()
- inv1.sort()
- if all1 == inv1:
- print 'BINGO!'
- else:
- print 'Sorry:', n, p
- print all
- print inv
-
-
- def rj(s, width):
- if type(s) is not type(''):
- s = `s`
-
- n = len(s)
- if n >= width:
- return s
-
- return ' ' * (width - n) + s
-
-
- def lj(s, width):
- if type(s) is not type(''):
- s = `s`
-
- n = len(s)
- if n >= width:
- return s
-
- return s + ' ' * (width - n)
-
-